package com.group3.hospital.controller;/*
 *@author 时崎
 * 2022/01/03
 */

import com.group3.hospital.bean.Subject;
import com.group3.hospital.service.SubjectService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Controller
public class NavigitionController {

    @Resource
    private SubjectService subjectService;
    //展示科室导航页面以及展示具体科室列表
    @RequestMapping("/navUi")
    public String navUi(Model model){
        List<Subject> nooperative = new ArrayList<>();
        List<Subject> operative = new ArrayList<>();
        List<Subject> diagnosis = new ArrayList<>();
        try {
            nooperative = subjectService.showNoOpe();
            operative = subjectService.showOpe();
            diagnosis = subjectService.showDiagnosis();

        } catch (Exception e) {
            e.printStackTrace();
        }
        model.addAttribute("nooperative",nooperative);
        model.addAttribute("operative",operative);
        model.addAttribute("diagnosis",diagnosis);
        return "navigation";
    }
    //根据具体科室名称查询科室
    @RequestMapping("/querySub")
    public String querySub(@RequestParam("subjectName") String subjectName,Model model,@RequestParam(value = "pn",defaultValue = "1") Integer pn){
        Subject subject = null;
        try {
             subject = subjectService.queryByName(subjectName);
        } catch (Exception e) {
            e.printStackTrace();
        }
       // List<Doctor> doctors = subject.getDoctors();

/*        PageInfo<Doctor> pageInfo = new PageInfo<>(doctors);
        model.addAttribute("pageInfo",pageInfo);*/
        model.addAttribute("subject",subject);
        return "subject_info";
    }




}
